package com.easy.service.impl;

import com.easy.bean.Record;
import com.easy.dao.IRecordDao;
import com.easy.service.IRecordService;
import com.easy.util.DateTimeConverter;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecordServiceImpl implements IRecordService {

    @Autowired
    IRecordDao dao;

    @Override
    public Record getDeliveryByID(int id) {
        return dao.getDeliveryByID(id);
    }
    @Override
    public Record getReceiptByID(int id) {
        return dao.getReceiptByID(id);
    }

    @Override
    public List<Record> getDelivery(Record record, Page page) {
        return dao.getDelivery(record,page);
    }
    @Override
    public List<Record> getReceipt(Record record, Page page) {
        return dao.getReceipt(record,page);
    }

    @Override
    public int getDeliveryCount(Record record) {
        return dao.getDeliveryCount(record);
    }
    @Override
    public int getReceiptCount(Record record) {
        return dao.getReceiptCount(record);
    }

    @Override
    public int addDelivery(Record record) {
        record.setTime(DateTimeConverter.convertToMySqlDateTime(record.getTime()));
        return dao.addDelivery(record);
    }
    @Override
    public int addReceipt(Record record) {
        record.setTime(DateTimeConverter.convertToMySqlDateTime(record.getTime()));
        return dao.addReceipt(record);
    }

    @Override
    public int delDelivery(int id) {
        return dao.delDelivery(id);
    }
    @Override
    public int delReceipt(int id) {
        return dao.delReceipt(id);
    }

    @Override
    public int editDelivery(Record record) {
        record.setTime(DateTimeConverter.convertToMySqlDateTime(record.getTime()));
        return dao.editDelivery(record);
    }
    @Override
    public int editReceipt(Record record) {
        record.setTime(DateTimeConverter.convertToMySqlDateTime(record.getTime()));
        return dao.editReceipt(record);
    }
}
